package io.renren.utils;

import org.apache.commons.beanutils.BeanUtilsBean2;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.converters.DateConverter;

import java.lang.reflect.InvocationTargetException;

public class BeanUtil {

    private BeanUtil() {
    }
    private static BeanUtil instance;

    public synchronized static BeanUtil getInstance(){
        return instance = new BeanUtil();
    }


    public void copy(Object source,Object target) throws InvocationTargetException, IllegalAccessException {
        ConvertUtils.register(new DateConverter(null), java.util.Date.class);
        BeanUtilsBean2.getInstance().copyProperties(target,source);
    }

}
